package com.example.demo.nettyaction;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * 通过启动顺序，指定spring boot 启动后首先
 * 启动EchoServer端
 */
@Order(1)
@Component
public class ServerRunner implements ApplicationRunner {
    @Autowired
    EchoServer echoServer;
    @Override
    public void run(ApplicationArguments applicationArguments) throws Exception {
        System.out.println("System run");
        new Thread(new Runnable() {
            @Override
            public void run() {
                echoServer.run();
            }
        }).start();
    }
}
